import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// import * as path from 'node:path'
import path from 'path'
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
import { viteMockServe } from 'vite-plugin-mock'

// https://vite.dev/config/
export default defineConfig((config)=>{
  console.log('config:',config)
  return {
    plugins: [
      vue(),
      createSvgIconsPlugin({
        // Specify the icon folder to be cached
        iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')],
        // Specify symbolId format
        symbolId: 'icon-[dir]-[name]',
      }),
      viteMockServe({
        mockPath: 'mock',
        enable: config.command === 'serve'
      })
    ],
    resolve: {
      alias: {
        // "@": path.resolve(__dirname, 'src'),
        "@": path.resolve("./src") // 相对路径别名配置，使用 @ 代替 src
      }
    },
    css: {
      preprocessorOptions: {
        scss: {
          // javascriptEnabled: true,
          additionalData: '@use "@/styles/variable.scss" as *;',
        },
        // scss: {
        //   additionalData: '@use "@/assets/style/variables.scss" as *;',
        // }
      },
    },
  }
})
